"use strict";
cc._RF.push(module, 'e2649AOr5JGpIdKWEHcK1Uy', 'WheelItemManage');
// scripts/WheelItemManage.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GameConstant"),
    s = t("CarConstant"),
    l = cc._decorator,
    c = l.ccclass,
    d = l.property,
    h = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.node_arrWheel = new Array(), e._nWheelType = 0, e._aEquipData = 0, e._carTag = 0, e.wheelJoint = null, e.collider = null, e._wheelPos = null, e.bOrientLeft = !1, e;
  }

  return n(e, t), e.prototype.init = function (t, e, o, i, n, a) {
    this._nWheelType = t, this._aEquipData = e, this._carTag = i;

    for (var s = 0; s < this.node_arrWheel.length; s++) {
      this.node_arrWheel[s].active = !1;
    }

    this.wheelJoint = this.node_arrWheel[t].getComponent(cc.WheelJoint), this.collider = this.node_arrWheel[t].getComponent(cc.PhysicsCircleCollider), this.wheelJoint.enableMotor = !1, this.wheelJoint.connectedBody = o, this.collider.tag = n;
    var l = a;

    switch (this._wheelPos = l, i) {
      case r.Physics_Car_Tag.Right:
        this.bOrientLeft = !0, l = cc.v3(-a.x, a.y, a.z), this.wheelJoint.motorSpeed = 0, this.wheelJoint.maxMotorTorque = 0;
        break;

      case r.Physics_Car_Tag.Left:
        this.bOrientLeft = !1, this.wheelJoint.motorSpeed = 0, this.wheelJoint.maxMotorTorque = 0;
    }

    this.initWheelPos(l), this.node_arrWheel[t].active = !0;
  }, e.prototype.initWheelPos = function (t) {
    this.node.position = t, r.Cur_Game_Type == r.Game_Type.PK ? (this.wheelJoint.connectedAnchor = cc.v2(t.x * r.Game_Type_Scale.PK, t.y * r.Game_Type_Scale.PK), this.collider.density = r.Game_Type_Scale.PK * this.collider.density) : this.wheelJoint.connectedAnchor = cc.v2(t.x, t.y);
  }, e.prototype.onGameStart = function () {
    this.wheelJoint.enableMotor = !0;
  }, e.prototype.onGameOver = function () {
    this.wheelJoint.enableMotor = !1, this.destroy();
  }, e.prototype.onGameBoutStart = function () {
    this.wheelJoint.enableMotor = !0;
  }, e.prototype.onGameBoutOver = function () {
    this.wheelJoint.enableMotor = !1;
  }, e.prototype.onMoveLeft = function (t) {
    t && this.onRrientLeft();
    var e = s.GetCarWheelData(this._aEquipData.id);
    this.wheelJoint.maxMotorTorque = e.MotorTorque * r.Game_Type_Wheel.PK, this.wheelJoint.motorSpeed = e.motorSpeed;
  }, e.prototype.onMoveRight = function (t) {
    t && this.onRrientRight();
    var e = s.GetCarWheelData(this._aEquipData.id);
    this.wheelJoint.maxMotorTorque = e.MotorTorque * r.Game_Type_Wheel.PK, this.wheelJoint.motorSpeed = -e.motorSpeed;
  }, e.prototype.onRrientLeft = function () {
    this.bOrientLeft || (this.bOrientLeft = !0, this.node.active = !1, this.node.scaleX = -this.node.scaleX, this.wheelJoint.node.scaleX = -this.wheelJoint.node.scaleX, this.node.position = cc.v3(-this._wheelPos.x, this._wheelPos.y, this._wheelPos.z), r.Cur_Game_Type == r.Game_Type.PK ? this.wheelJoint.connectedAnchor = cc.v2(-this._wheelPos.x * r.Game_Type_Scale.PK, this._wheelPos.y * r.Game_Type_Scale.PK) : this.wheelJoint.connectedAnchor = cc.v2(-this._wheelPos.x, this._wheelPos.y), this.node.active = !0);
  }, e.prototype.onRrientRight = function () {
    this.bOrientLeft && (this.bOrientLeft = !1, this.node.active = !1, this.node.scaleX = -this.node.scaleX, this.wheelJoint.node.scaleX = -this.wheelJoint.node.scaleX, this.node.position = cc.v3(this._wheelPos.x, this._wheelPos.y, this._wheelPos.z), r.Cur_Game_Type == r.Game_Type.PK ? this.wheelJoint.connectedAnchor = cc.v2(this._wheelPos.x * r.Game_Type_Scale.PK, this._wheelPos.y * r.Game_Type_Scale.PK) : this.wheelJoint.connectedAnchor = cc.v2(this._wheelPos.x, this._wheelPos.y), this.node.active = !0);
  }, e.prototype.onMoveCancel = function () {
    this.wheelJoint.maxMotorTorque = 0, this.wheelJoint.motorSpeed = 0;
  }, e.prototype.onAirShipIn = function () {
    this.node.active = !1;
  }, e.prototype.onAirShipOut = function () {
    switch (this._carTag) {
      case r.Physics_Car_Tag.Right:
      case r.Physics_Car_Tag.Left:
        this.wheelJoint.motorSpeed = 0, this.wheelJoint.maxMotorTorque = 0;
    }

    this.node.active = !1, this.bOrientLeft ? (this.node.position = cc.v3(-this._wheelPos.x, this._wheelPos.y, this._wheelPos.z), r.Cur_Game_Type == r.Game_Type.PK ? this.wheelJoint.connectedAnchor = cc.v2(-this._wheelPos.x * r.Game_Type_Scale.PK, this._wheelPos.y * r.Game_Type_Scale.PK) : this.wheelJoint.connectedAnchor = cc.v2(-this._wheelPos.x, this._wheelPos.y)) : (this.node.position = cc.v3(this._wheelPos.x, this._wheelPos.y, this._wheelPos.z), r.Cur_Game_Type == r.Game_Type.PK ? this.wheelJoint.connectedAnchor = cc.v2(this._wheelPos.x * r.Game_Type_Scale.PK, this._wheelPos.y * r.Game_Type_Scale.PK) : this.wheelJoint.connectedAnchor = cc.v2(this._wheelPos.x, this._wheelPos.y)), this.node.active = !0;
  }, e.prototype.onDisassembly = function () {
    this.wheelJoint.connectedBody = null, this.wheelJoint.node.active = !1;
  }, e.prototype.getEquipData = function () {
    return this._aEquipData;
  }, e.prototype.getIndex = function () {
    return this._nWheelType;
  }, e.prototype.getPos = function () {
    return this.wheelJoint.node.convertToWorldSpaceAR(cc.Vec3.ZERO);
  }, e.prototype.getRadius = function () {
    return this.wheelJoint.node.active ? this.collider.radius : 0;
  }, a([d(cc.Node)], e.prototype, "node_arrWheel", void 0), a([c], e);
}(cc.Component);

o["default"] = h;

cc._RF.pop();